<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./WEB-INF/templates/turnitup_template.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="top">
        <ui:include src="./WEB-INF/templates/logo_bar.xhtml"/>
        <p:breadCrumb>
            <p:menuitem outcome="index"/>
            <p:menuitem value="#{webtext.access}" url="#"/>
        </p:breadCrumb>
    </ui:define>

    <ui:define name="menu_left">
    </ui:define>

    <ui:define name="basket">
    </ui:define>

    <ui:define name="content">
        <h:panelGroup layout="block" id="content_panel">
            <p:messages id="messages_access" showDetail="true" autoUpdate="true" closable="true" />
            <h:panelGroup layout="block" id="login">
                <h:outputText styleClass="content_title" value="#{webtext.isCustomer}"/>
            <h:form>
                <h:panelGrid id="grid_login" columns="3" cellpadding="3">
                    <h:outputLabel value="#{webtext.email}" for="email_login" />
                    <p:inputText id="email_login" value="#{userController.selected.email}" required="true" requiredMessage="#{webtext.requiredMessage_email}" validatorMessage="#{webtext.validation_email}">
                        <f:validateRegex pattern="[a-zA-Z0-9]+@[a-zA-Z0-9]+\.[a-zA-Z0-9]+"/>
                    </p:inputText>
                    <p:message for="email_login"/>
                    
                    <h:outputLabel value="#{webtext.password}" for="pass_login" />
                    <p:password id="pass_login" value="#{userController.selected.password}" required="true" requiredMessage="#{webtext.requiredMessage_password}"/>
                    <p:message for="pass_login"/>
                </h:panelGrid>
                <p:commandButton update="grid_login" value="#{webtext.login}" action="#{userController.checkLogin}"/>
            </h:form>
            </h:panelGroup>
        </h:panelGroup>
        
        
        <h:panelGroup id="register" layout="block">
            <h:outputText styleClass="content_title" value="#{webtext.isNotCustomer}"/>
            <h:form>
                <h:panelGrid id="grid_reg" columns="3" cellpadding="3">
                    
                    <h:outputLabel value="#{webtext.name}" for="name" />
                    <p:inputText id="name" value="#{userController.selected.name}" required="true" requiredMessage="#{webtext.requiredMessage_name}"/>
                    <p:message for="name"/>
                    
                    <h:outputLabel value="#{webtext.surname}" for="surname" />
                    <p:inputText id="surname" value="#{userController.selected.surname}" required="true" requiredMessage="#{webtext.requiredMessage_surname}"/>
                    <p:message for="surname"/>
                    
                    <h:outputLabel value="#{webtext.email}" for="email_reg" />
                    <p:inputText id="email_reg" value="#{userController.selected.email}" required="true" requiredMessage="#{webtext.requiredMessage_email}" validatorMessage="#{webtext.validation_email}">
                        <f:validateRegex pattern="[a-zA-Z0-9]+@[a-zA-Z0-9]+\.[a-zA-Z0-9]+"/>
                    </p:inputText>
                    <p:message for="email_reg"/>
                    
                    <h:outputLabel value="#{webtext.password}" for="pass_reg" />
                    <p:password id="pass_reg" value="#{userController.selected.password}" required="true" requiredMessage="#{webtext.requiredMessage_password}" feedback="true" match="pass2_reg" validatorMessage="#{webtext.validation_password}"/>
                    <p:message for="pass_reg"/>
                    
                    <h:outputLabel value="#{webtext.password2}" for="pass2_reg" />
                    <p:password id="pass2_reg" value="#{userController.selected.password}" required="true" requiredMessage="#{webtext.requiredMessage_password}"/>
                    <p:message for="pass2_reg"/>
                      
                    <h:outputLabel value="#{webtext.phone}" for="phone" />
                    <p:inputText type="number" id="phone" value="#{userController.selected.phone}" required="true" requiredMessage="#{webtext.requiredMessage_phone}" validatorMessage="#{webtext.validation_phone}">
                        <f:validateLength minimum="9" maximum="9"/>
                        <f:validateLongRange minimum="1"/>
                    </p:inputText>  
                    <p:message for="phone"/>
                    
                    <h:outputLabel value="#{webtext.address}" for="address" />
                    <p:inputText id="address" value="#{userController.selected.address}" required="true" requiredMessage="#{webtext.requiredMessage_address}"/>
                    <p:message for="address"/>
                    
                    <h:outputLabel value="#{webtext.country}" for="country" />
                    <p:inputText id="country" value="#{userController.selected.country}" required="true" requiredMessage="#{webtext.requiredMessage_country}"/>
                    <p:message for="country"/>
                    
                    <h:outputLabel value="#{webtext.city}" for="city" />
                    <p:inputText id="city" value="#{userController.selected.city}" required="true" requiredMessage="#{webtext.requiredMessage_city}"/>
                    <p:message for="city"/>
                    
                    <h:outputLabel value="#{webtext.postal_code}" for="postal_code" />
                    <p:inputText type="number" id="postal_code" value="#{userController.selected.postalCode}" required="true" requiredMessage="#{webtext.requiredMessage_postal_code}" validatorMessage="#{webtext.validation_pcode}">
                        <f:validateLength minimum="5" maximum="5"/>
                        <f:validateLongRange minimum="1"/>
                    </p:inputText>
                    <p:message for="postal_code"/>      
                </h:panelGrid>
                <p:commandButton update="grid_reg"  value="#{webtext.register}" action="#{userController.checkRegister}">
                    <f:setPropertyActionListener target="#{userController.selected.type}" value="#{webtext.usertype_customer}"/>
                </p:commandButton>
            </h:form>
        </h:panelGroup>
        
        <h:button value="#{webtext.back}" outcome="index"/>
            

    </ui:define>

    <ui:define name="footer">
        <ui:include src="./WEB-INF/templates/footer.xhtml"/>
    </ui:define>

</ui:composition>
